Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor code tweaks/optimizations (PHP) #43375

Merged
merged 1 commit into from
Aug 29, 2022
Merged

Minor code tweaks/optimizations (PHP) #43375

merged 1 commit into from
Aug 29, 2022

Conversation

aristath
Copy link
Member

What?

Just some minor code optimizations. Details in comments for each change.

@aristath aristath requested a review from spacedmonkey as a code owner August 18, 2022 11:29
Comment on lines -15 to -17
// Determine if any border related features are supported.
$has_border_support = block_has_support( $block_type, array( '__experimentalBorder' ) );
$has_border_color_support = gutenberg_has_border_feature_support( $block_type, 'color' );
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are only used once, so we don't need to assign them to a var.

@@ -48,9 +44,7 @@ function gutenberg_apply_border_support( $block_type, $block_attributes ) {
return array();
}

$sides = array( 'top', 'right', 'bottom', 'left' );
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$sides is only used once, no need to assign it to a var

$color_support = false;
if ( property_exists( $block_type, 'supports' ) ) {
$color_support = _wp_array_get( $block_type->supports, array( 'color' ), false );
}
$color_support = property_exists( $block_type, 'supports' ) ? _wp_array_get( $block_type->supports, array( 'color' ), false ) : false;
Copy link
Member Author

@aristath aristath Aug 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Short and sweet

@skorasaurus skorasaurus added the [Type] Code Quality Issues or PRs that relate to code quality label Aug 19, 2022
@aristath aristath requested a review from ntsekouras August 29, 2022 11:52
Copy link
Contributor

@ntsekouras ntsekouras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks Ari!

@aristath aristath merged commit 0cb2f52 into trunk Aug 29, 2022
@aristath aristath deleted the try/minor-tweaks-047 branch August 29, 2022 11:57
@github-actions github-actions bot added this to the Gutenberg 14.1 milestone Aug 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Code Quality Issues or PRs that relate to code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants